<template>
  <div class="area-wraper gc-flex-item" ref="wraper">
    <div>
      <div class="area"
           v-for="(item, index) of cities"
           :key="index"
           :ref="index">
        <div class="area_title">{{index}}</div>
        <div class="area_wraper">
          <div class="area_list" v-for="innerItem of item" :key="innerItem.id">
            {{innerItem.name}}
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script type="es6">
import BScroll from 'better-scroll'
export default {
  name: '',
  props: {
    cities: Object,
    letter: String
  },
  mounted () {
    this.scroll = new BScroll(this.$refs.wraper)
  },
  watch: {
    letter () {
      if (this.letter) {
        const element = this.$refs[this.letter][0]
        this.scroll.scrollToElement(element)
      }
    }
  }
}
</script>

<style scoped lang="less">
  .area-wraper{
    overflow: hidden;
  }
  .area_title{
    padding: .10rem;
  }
  .area_wraper{
    background: #fff;
    padding: 0 .10rem;
  .area_list{
    padding: .10rem 0;
    border-bottom: .01rem solid #e6e6e6;
  &:last-child{
     border-bottom: none;
   }
  }
  }
</style>
